//
// Created by Administrator on 2023/11/14.
//
#include "iostream"

using namespace std;
const int N = 1e3;
int diff[N][N];

void insert(int x1, int y1, int x2, int y2, int c) {
    diff[x1][y1] += c;
    diff[x1][y2 + 1] -= c;
    diff[x2 + 1][y1] -= c;
    diff[x2 + 1][y2 + 1] += c;
}

int main() {
    int n, m, q;
    cin >> n >> m >> q;

    // 不需要sum Sum[n + 1][m + 1],直接利用insert在某一点具体插入即可,之后累加求和可求出diff


    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            int x;
            cin >> x;
            insert(i, j, i, j, x);
        }
    }

    while (q--) {
        int x1, y1, x2, y2, c;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        insert(x1, y1, x2, y2, c);
    }


    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {

            diff[i][j] += diff[i - 1][j] + diff[i][j - 1] - diff[i - 1][j - 1];//差分求和
            cout << diff[i][j] << ' ';
        }
        cout << endl;
    }
}